library(tidyverse)
## -- Attaching packages -------------------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.2.1 v purrr 0.3.3
## v tibble 2.1.3 v dplyr 0.8.3
## v tidyr 1.0.2 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## -- Conflicts ----------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
SNPs<- read.table("23andMe_complete.txt",header = TRUE, sep = "\t")
#EXERCISE 1
BarGraph1 <- ggplot(data = SNPs) + geom_bar(mapping = aes(x=chromosome), fill ="blue") + ggtitle("Hamza")
BarGraph1
#Exercise 2
Graph3 <- ggplot(data = SNPs) + geom_bar(mapping = aes(x = chromosome, fill= genotype)) + ggtitle("Hamza")
Graph3 + ylab("Genotype Count")+ xlab("Chromosome number")
mycolor<-c("AA"="green","AC"="green","AG"="green","AT"="green","CC"="green","CG"="green","CT"="green","D"="purple","DD"="purple","DI"="purple","GG"="green","GT"="green","I"="purple","II"="purple","TT" ="green","A"="blue","C"="blue","G"="blue","T"="blue","--"="black")
Graph3 + scale_fill_manual(values=mycolor)
#Exercise 3
Genotype counts per chromosome
#Exercise 4
Total SNPs each chromosome
#Exercise 5
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
Graph5 <- ggplotly(ggplot(data = SNPs) + geom_bar(mapping = aes(x = chromosome, fill= genotype), position = "dodge") + facet_wrap(~genotype, ncol = 2, nrow = 15) + ggtitle("Total SNPs each chromosome") + ylab("Genotype Count") + xlab("Chromosome Numbers"), width = 1000, height = 1000)
Graph5[["x"]][["layout"]][["annotations"]][[2]][["x"]] <- -0.05
Graph5
#Excercise 6
library(DT)
R <- subset(SNPs, chromosome == "Y" )
datatable(R)
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html